#ifndef VARIANTMODEL_H
#define VARIANTMODEL_H

#include <QtCore/QAbstractItemModel>

class VariantModel : public QAbstractItemModel
{
	Q_OBJECT

public:
	VariantModel(const QVariant &var = QVariant(), QObject *parent = 0);
	~VariantModel();

	void setVariant(const QVariant& var);
	QVariant value() const;
	static bool isCollection(QVariant::Type type);
	void append(QVariant value, const QString& key = QString());
	void deleteAt(const QModelIndex & index);

	virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
	virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
	virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
	virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
	virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
	virtual QModelIndex parent ( const QModelIndex & index ) const;

	virtual Qt::ItemFlags flags(const QModelIndex &index) const;
	virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); 

//signals:
//	void toCollectionType();

private:
	bool convert(QVariant& var, int type);
	QVariant mVar;
	QMap<int, QString> mMapped;
};

#endif // VARIANTMODEL_H
